package
{
	import org.robotlegs.base.ContextEvent;
	import org.robotlegs.mvcs.Context;
	

	import controller.main.CommandBrowseForFile;
	import controller.main.CommandFilesSelected;
	import controller.main.CommandInit;
	import controller.main.CommandSaveProject;
	import controller.main.CommandLoadProject;
	import controller.main.CommandNewProject;
	import controller.library.CommandRemoveLibraryItem;
	import controller.library.CommandAddResourcesToLibrary;
	import controller.library.CommandUpdateLibraryResource;
	import controller.library.CommandCreateNewLibraryItem;
	import controller.library.CommandResolveLibraryConflict;
	import controller.library.CommandSetLibraryItemProperty;
	import controller.room.CommandSetObjectsProperty;
	import controller.room.CommandSetRoomProperty;
	import controller.room.CommandCreateNewRoom;
	import controller.room.CommandSetSelection;
	import controller.room.CommandSetTilesProperty;
	import controller.room.CommandCurrentPerspectiveChange;
	import controller.room.CommandRemoveRoomItems;
	import controller.room.CommandRemoveRooms;
	import controller.room.CommandAddItemToRoom;

	import events.main.EventBrowseForFiles;
	import events.main.EventFilesSelect;
	import events.main.EventLoadProject;
	import events.main.EventNewProject;
	import events.main.EventSaveProject;
	import events.room.EventAddItemToRoom;
	import events.room.EventCreateNewRoom;
	import events.room.EventRemoveRoomItems;
	import events.room.EventRemoveRooms;
	import events.room.EventCurrentPerspectiveChange;
	import events.room.EventSetObjectsProperty;
	import events.room.EventSetRoomProperty;
	import events.room.EventSetSelection;
	import events.room.EventSetTilesProperty;
	import events.library.EventUpdateLibraryResource;
	import events.library.EventSetLibraryItemProperty;
	import events.library.EventSetLibraryItemProperty;
	import events.library.EventAddResourcesToLibrary;
	import events.library.EventCreateNewLibraryItem;
	import events.library.EventRemoveLibraryItems;
	import events.library.EventResolveLibraryConflict;
	
	import model.ModelBrowseFile;
	import model.ModelLibrary;
	import model.ModelLibraryConflicts;
	import model.ModelProject;
	import model.ModelRooms;
	import model.ModelSelection;
	
	import services.IServiceAppInfo;
	import services.IServiceBrowseForFiles;
	import services.IServiceFile;
	import services.ServiceAppInfo;
	import services.ServiceBrowseForFile;
	import services.ServiceFile;
	
	import view.MainView;
	import view.MediatorMainView;
	import view.itemRenderes.ItemRendererIsoRoom;
	import view.itemRenderes.ItemRendererLImage;
	import view.itemRenderes.ItemRendererLObject;
	import view.itemRenderes.ItemRendererLTile;
	import view.itemRenderes.ItemRendererLbinaryData;
	import view.itemRenderes.mediators.MediatorItemRendererIsoRoom;
	import view.itemRenderes.mediators.MediatorItemRendererLBinaryData;
	import view.itemRenderes.mediators.MediatorItemRendererLImage;
	import view.itemRenderes.mediators.MediatorItemRendererLObject;
	import view.itemRenderes.mediators.MediatorItemRendererLTile;
	import view.library.MediatorScreenBinaries;
	import view.library.MediatorScreenImages;
	import view.library.MediatorScreenLibrary;
	import view.library.MediatorScreenObjects;
	import view.library.MediatorScreenTiles;
	import view.library.PopupLibraryConflicts;
	import view.library.ScreenBinaries;
	import view.library.ScreenImages;
	import view.library.ScreenLibrary;
	import view.library.ScreenObjects;
	import view.library.ScreenTiles;
	import view.library.MediatorPopupLibraryConflicts;
	import view.rooms.MediatorScreenRooms;
	import view.rooms.ScreenRooms;
	import view.xml.MediatorScreenXML;
	import view.xml.ScreenXML;

	public class IsoEditorContext extends Context {
		
		public function IsoEditorContext() {
			super(null, true);
		}
		override public function startup() : void {
			
			//Model
			injector.mapSingleton(ModelLibrary);
			injector.mapSingleton(ModelRooms);
			injector.mapSingleton(ModelProject);
			injector.mapSingleton(ModelBrowseFile);
			injector.mapSingleton(ModelSelection);
			injector.mapSingleton(ModelLibraryConflicts);
			
			//services
			injector.mapSingletonOf(IServiceFile, ServiceFile);
			injector.mapSingletonOf(IServiceBrowseForFiles, ServiceBrowseForFile);
			injector.mapSingletonOf(IServiceAppInfo, ServiceAppInfo);
			
			//mediators
			mediatorMap.mapView(MainView, MediatorMainView);
			mediatorMap.mapView(ScreenRooms, MediatorScreenRooms);
			mediatorMap.mapView(ScreenTiles, MediatorScreenTiles);
			mediatorMap.mapView(ScreenObjects, MediatorScreenObjects);
			mediatorMap.mapView(ScreenLibrary, MediatorScreenLibrary);
			mediatorMap.mapView(ScreenImages, MediatorScreenImages);
			mediatorMap.mapView(ScreenBinaries, MediatorScreenBinaries);
			mediatorMap.mapView(ItemRendererLImage, MediatorItemRendererLImage);
			mediatorMap.mapView(ItemRendererLObject, MediatorItemRendererLObject);
			mediatorMap.mapView(ItemRendererLTile, MediatorItemRendererLTile);
			mediatorMap.mapView(ItemRendererLbinaryData, MediatorItemRendererLBinaryData);
			mediatorMap.mapView(ItemRendererIsoRoom, MediatorItemRendererIsoRoom);
			mediatorMap.mapView(PopupLibraryConflicts, MediatorPopupLibraryConflicts);
			mediatorMap.mapView(ScreenXML, MediatorScreenXML);

			//commands
			commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, CommandInit, ContextEvent);
			commandMap.mapEvent(EventRemoveLibraryItems.REMOVE_LIBRARY_ITEM, CommandRemoveLibraryItem, EventRemoveLibraryItems);
			commandMap.mapEvent(EventCreateNewLibraryItem.CREATE_NEW_BINARY, CommandCreateNewLibraryItem, EventCreateNewLibraryItem);
			commandMap.mapEvent(EventCreateNewLibraryItem.CREATE_NEW_IMAGE, CommandCreateNewLibraryItem, EventCreateNewLibraryItem);
			commandMap.mapEvent(EventCreateNewLibraryItem.CREATE_NEW_OBJECT, CommandCreateNewLibraryItem, EventCreateNewLibraryItem);
			commandMap.mapEvent(EventCreateNewLibraryItem.CREATE_NEW_TILE, CommandCreateNewLibraryItem, EventCreateNewLibraryItem);
			commandMap.mapEvent(EventSetLibraryItemProperty.CHANGE_LIBRARY_ITEM_PROPERTY, CommandSetLibraryItemProperty, EventSetLibraryItemProperty);
			commandMap.mapEvent(EventBrowseForFiles.BROWSE_FOR_FILES, CommandBrowseForFile, EventBrowseForFiles);
			commandMap.mapEvent(EventFilesSelect.FILES_SELECT, CommandFilesSelected, EventFilesSelect);
			commandMap.mapEvent(EventCreateNewRoom.CREATE_NEW_ROOM, CommandCreateNewRoom, EventCreateNewRoom);
			commandMap.mapEvent(EventAddItemToRoom.ADD_ITEM_TO_ROOM, CommandAddItemToRoom, EventAddItemToRoom);
			commandMap.mapEvent(EventSetRoomProperty.CHANGE_PROPERTY, CommandSetRoomProperty, EventSetRoomProperty);
			commandMap.mapEvent(EventSetSelection.SET_SELECTION, CommandSetSelection, EventSetSelection);
			commandMap.mapEvent(EventSetTilesProperty.TILES_PROPERTY_CHAGE, CommandSetTilesProperty, EventSetTilesProperty);
			commandMap.mapEvent(EventSetObjectsProperty.OBJECTS_PROPERTY_CHAGE, CommandSetObjectsProperty, EventSetObjectsProperty);
			commandMap.mapEvent(EventRemoveRooms.REMOVE_ROOM, CommandRemoveRooms, EventRemoveRooms);
			commandMap.mapEvent(EventRemoveRoomItems.REMOVE_ROOM_ITEMS, CommandRemoveRoomItems, EventRemoveRoomItems);
			commandMap.mapEvent(EventSaveProject.SAVE_PROJECT, CommandSaveProject, EventSaveProject);
			commandMap.mapEvent(EventLoadProject.LOAD_PROJECT, CommandLoadProject, EventLoadProject);
			commandMap.mapEvent(EventNewProject.NEW_PROJECT, CommandNewProject, EventNewProject);
			commandMap.mapEvent(EventCurrentPerspectiveChange.ROOM_SELECTION_CHANGE, CommandCurrentPerspectiveChange, EventCurrentPerspectiveChange);
			commandMap.mapEvent(EventResolveLibraryConflict.RESOLVE_LIBRARY_CONFLICT, CommandResolveLibraryConflict, EventResolveLibraryConflict);
			commandMap.mapEvent(EventAddResourcesToLibrary.ADD_RESOURCE_TO_LIBRARY, CommandAddResourcesToLibrary, EventAddResourcesToLibrary);
			commandMap.mapEvent(EventUpdateLibraryResource.UPDATE_LIBRARY_RESOURCE, CommandUpdateLibraryResource, EventUpdateLibraryResource);

			dispatchEvent(new ContextEvent(ContextEvent.STARTUP));
		}

		
		
	}
}